home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0"?>
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:output method="html" encoding="ISO-8859-1" indent="yes"/>
- <!-- Orders the output of books based on a priority based on -->
- <!-- the occurence of given words in the title of the book -->
- <!-- e.g. 1st are any books with 'XSL' in the title -->
- <!-- 2nd are any books with 'ASP' in the title -->
- <!-- 3rd are any books with 'Java' in the title -->
- <!-- then all other books are listed as is -->
- <xsl:template match="/">
- <html>
- <head>
- <title>Books by interest priority</title>
- </head>
- <body>
- <h3>Books by interest priority</h3>
- <table border="1">
- <tr>
- <th>Title</th>
- <th>Author</th>
- <th>ISBN</th>
- <th>Item No.</th>
- </tr>
- <xsl:apply-templates select="/books/book">
- <xsl:sort select="number(contains(title,'XSL'))" data-type="number" order="descending"/>
- <xsl:sort select="number(contains(title,'ASP'))" data-type="number" order="descending"/>
- <xsl:sort select="number(contains(title,'Java'))" data-type="number" order="descending"/>
- </xsl:apply-templates>
- </table>
- </body>
- </html>
- </xsl:template>
-
- <xsl:template match="book">
- <tr>
- <td><xsl:value-of select="title"/></td>
- <td><xsl:value-of select="author"/></td>
- <td><xsl:value-of select="@isbn"/></td>
- <!-- show position of element in original xml -->
- <td align="right"><xsl:value-of select="count(preceding-sibling::book)+1"/></td>
- </tr>
- </xsl:template>
-
- </xsl:stylesheet>